<?php
class Admin_Users_Controller extends MyZend_Controller_Action {
	// array param 
	protected $_arrParam;
	
	protected $_actionMain;
	
	protected $_currentController;
	
	protected $_namespace;
	
	protected $_paginator = array(
			                       'itemCountPerPage' => 5,
			                       'pageRange' => 4
			                     );
	
	public function init() {
	
		$this->_arrParam          = $this->_request->getParams();
		$this->_currentController = '/' . $this->_arrParam['module']
		. '/' . $this->_arrParam['controller'];
	
		$this->_actionMain        = '/' . $this->_arrParam['module']
		. '/' . $this->_arrParam['controller'] . '/index';
	
		// filter session
		$this->_namespace         = $this->_arrParam['module'] . '-' . $this->_arrParam['controller'];
		$ssFilter = new Zend_Session_Namespace($this->_namespace);
		// save session filter
		if(empty($ssFilter->col)){
			$ssFilter->col   = 'g.id';
			$ssFilter->order = 'DESC';
		}
	
		/*if(($this->_arrParam['action'] != 'filter') && ($this->_arrParam['action'] != 'index')) {
		 $ssFilter->col   = 'g.id';
		$ssFilter->order = 'DESC';
		}*/
		$this->_arrParam['ssFilter']['col'] 		= $ssFilter->col;
		$this->_arrParam['ssFilter']['order'] 		= $ssFilter->order;
	
	
		// paginator
		$this->_paginator['currentPage'] = $this->_request->getParam('page',1);
		$this->_arrParam['paginator']    = $this->_paginator;
	
		// render to view
		$this->view->arrParam 		   = $this->_arrParam;
		$this->view->actionMain 	   = $this->_actionMain;
		$this->view->currentController = $this->_currentController;
	
		$this->_helper->layout()->disableLayout();
		$template_path = TEMPLATE_PATH . '/admin/main';
		$this->loadTemplate($template_path);
	}
	
}